package com.lsk.util;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 格式化时间
 */
public class UtilDataFormat {
    public static String formatData(Date date, String format) {
        SimpleDateFormat time = new SimpleDateFormat(format);//" HH mm ss"
        return time.format(date);
    }

    public static String restoreDate(String data) {
        BigDecimal bd = new BigDecimal(data);
        String temp = bd.toPlainString();
        Long l = Long.parseLong(temp) * 1000L;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String result = sdf.format(l);
        return result;
    }
}
